<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>KillThread</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<font face="Arial" size="2"><p align="center"><b><font size="4">KillThread()</font></b></p>
<p><b>Syntax</b></p><blockquote>
<font color="#006666"><b>KillThread</b></font>(Thread)</blockquote>

</blockquote>
<b>Description</b><br><blockquote>



Immediately kills the specified thread, which had previously been created with <a href="createthread.html">CreateThread()</a>. This is 
a very dangerous function, and should only be used rarely. The problem is that the thread is killed immediately 
and has no chance to perform any cleanup code (for example, freeing memory, releasing items, 
de-allocating its own stack). 
<br>
<br>
If possible, a flag like a global variable should be used to tell the thread to quit itself (which does the needed cleanup) 
and this function should only be used if this is not possible for some reason. 

 

</blockquote><p><b>Parameters</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>Thread</i></td>
<td width="90%"> 
 
The thread to kill. This value is returned by <a href="createthread.html">CreateThread()</a>. 

 

</td></tr>
</table>
</blockquote><p><b>Return value</b></p><blockquote>

None.





</blockquote><p><b>Example</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <font color="#006666">; A procedure/thread which will never exit. Not good, but it</font>
  <font color="#006666">; shows how KillThread works </font>
  <b><font color="#006666">Procedure</font></b> <font color="#006666">PrintStuff</font>(*Interval)
    <b><font color="#006666">Repeat</font></b>
<font color="#006666">      PrintN</font>(".")
<font color="#006666">      Delay</font>(*Interval)
    <b><font color="#006666">ForEver</font></b>
  <b><font color="#006666">EndProcedure</font></b>
  
  <b><font color="#006666">If</font></b> <font color="#006666">OpenConsole</font>()
    thread =<font color="#006666"> CreateThread</font>(@PrintStuff(), 500)
    <b><font color="#006666">If</font></b> thread
      <b><font color="#006666">For</font></b> i=0 <b><font color="#006666">To</font></b> 10
<font color="#006666">        PrintN</font>("A")
<font color="#006666">        Delay</font>(999)
  
        <b><font color="#006666">If</font></b> i=5
<font color="#006666">          KillThread</font>(thread)
        <b><font color="#006666">EndIf</font></b>
      <b><font color="#006666">Next</font></b>
    <b><font color="#006666">EndIf</font></b>
  <b><font color="#006666">EndIf</font></b>
</font></pre>

</Blockquote><p><b>Supported OS  </b><Blockquote>All</Blockquote></p><center>&lt;- <a href=isthread.html>IsThread()</a> - <a href=index.html>Thread Index</a> - <a href=lockmutex.html>LockMutex()</a> -&gt;



</body></html>